package com.bootdo.act.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bootdo.act.dao.InviteRecordDao;
import com.bootdo.act.dao.TeamUserDao;
import com.bootdo.act.domain.InviteRecordDO;
import com.bootdo.act.domain.TeamUserDO;
import com.bootdo.act.service.InviteRecordService;



@Service
public class InviteRecordServiceImpl implements InviteRecordService {
	@Autowired
	private InviteRecordDao inviteRecordDao;
	
	@Autowired
	private TeamUserDao teamUserDao;
	
	@Override
	public InviteRecordDO get(Long id){
		return inviteRecordDao.get(id);
	}
	
	@Override
	public List<InviteRecordDO> list(Map<String, Object> map){
		return inviteRecordDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return inviteRecordDao.count(map);
	}
	
	@Override
	public int save(InviteRecordDO inviteRecord){
		return inviteRecordDao.save(inviteRecord);
	}
	
	@Override
	public int update(InviteRecordDO inviteRecord){
		return inviteRecordDao.update(inviteRecord);
	}
	
	@Override
	public int remove(Long id){
		return inviteRecordDao.remove(id);
	}
	
	@Override
	public int batchRemove(Long[] ids){
		return inviteRecordDao.batchRemove(ids);
	}

	@Override
	public int reply(InviteRecordDO recordDO) {
		int update = inviteRecordDao.update(recordDO);
		if(recordDO.getIsAgree()==1){//同意，插入关联
			TeamUserDO teamUserDO = new TeamUserDO();
			teamUserDO.setTeamId(recordDO.getTeamId());
			teamUserDO.setUserId(recordDO.getUserId());
			teamUserDO.setUserName(recordDO.getUserName());
			teamUserDao.save(teamUserDO);
		}
		return update;
	}
	
}
